import React, { Component } from 'react';
// 引入校验
import PropTypes from 'prop-types'
import Item from '../Item';
import list from './index.module.css';

export default class List extends Component {
  // 校验传入参数
  static propTypes = {
    todos: PropTypes.array.isRequired,
    updateTodo: PropTypes.func.isRequired,
    deleteTodo: PropTypes.func.isRequired
  }

  render() {
    const { todos, updateTodo, deleteTodo} = this.props;
    return (
      <ul className={list['todo-main']}>
        {
          todos.map(todo => {
            return <Item key={todo.id} {...todo} updateTodo={updateTodo} deleteTodo={deleteTodo}></Item>;
          })
        }
      </ul>
    );
  }
}
